//
//  TeacherInfoHeaderView.m
//  SDSY
//
//  Created by 蓝布鲁 on 2017/4/10.
//  Copyright (c) 2017 蓝布鲁. All rights reserved.
//

#import "StudentInfoHeaderView.h"

@interface StudentInfoHeaderView()

@property (nonatomic, retain)UIImageView *imageView;            // 导师头像
@property (nonatomic, retain)UILabel *nameLabel;                // 导师名


@end

@implementation StudentInfoHeaderView



- (instancetype)initWithFrame:(CGRect)frame {
    if (self=[super initWithFrame:frame]) {
        [self setupView];
    }
    return self;
}

// 初始化view
-(void)setupView {
    self.backgroundColor = [UIColor clearColor];
    // 创建半透明特效
    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
    effectView.alpha = 0.95;
    [self addSubview:effectView];

    // 导师头像
    self.imageView = [[UIImageView alloc] init];
    self.imageView.layer.masksToBounds = true;
    self.imageView.layer.cornerRadius = 30;
    [effectView.contentView addSubview:self.imageView];

    

    // 导师名
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.font = [UIFont systemFontOfSize:15];
    [effectView.contentView addSubview:self.nameLabel];


    // 设置布局
    self.imageView.sd_layout.topSpaceToView(effectView.contentView,10).leftSpaceToView(effectView.contentView,10).heightIs(60).widthIs(60);
    self.nameLabel.sd_layout.topEqualToView(self.imageView).leftSpaceToView(self.imageView,10).widthIs(150).heightIs(17);

    // 设置HeaderView的高度，设置效果层大小
    [effectView setupAutoHeightWithBottomView:self.imageView bottomMargin:10];
    effectView.sd_layout.topSpaceToView(self,0).leftSpaceToView(self,0).rightSpaceToView(self,0);

    [self setupAutoHeightWithBottomView:effectView bottomMargin:0];

}

// 刷新view
- (void)setModel:(StudentInfoModel *)model {
    // 导师头像
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.image] placeholderImage:[UIImage imageNamed:@"avatar_default"]];

    // 导师名
    self.nameLabel.text = model.name;


}

@end
